jQuery(document).ready(function($) {
	$('.demo-open-close').click(function() {
		if ($(this).parent().css('left') == '-268px') {
			$(this).parent().animate({
				"left": "0"
			}, 300);
		} else {
			$(this).parent().animate({
				"left": "-268px"
			}, 300);
		}
	});
	
	sg_demo_val = {};
	if($.cookie("theme-color")) {
		sg_demo_val.color_id = $.cookie("theme-color");
		sg_demo_val.color = $.cookie("Theme|color");
		$('#' + $.cookie("theme-color")).addClass('active');
	}
	if($.cookie("body-pattern")) {
		sg_demo_val.pattern_id = $.cookie("body-pattern");
		sg_demo_val.pattern = $.cookie("Theme|pattern");
		$('#' + $.cookie("body-pattern")).addClass('active');
	}

	$('.theme-changer-wrap a.demo-color').click(function() {
		$('.theme-changer-wrap a.demo-color').removeClass('active');
		$(this).addClass('active');
		sg_demo_val.color_id = $(this).attr('id');
		sg_demo_val.color = $(this).attr('rel');
		return false;
	});

	$('.theme-changer-wrap a.demo-pattern').click(function() {
		$('.theme-changer-wrap a.demo-pattern').removeClass('active');
		$(this).addClass('active');
		sg_demo_val.pattern_id = $(this).attr('id');
		sg_demo_val.pattern = $(this).attr('rel');
		return false;
	});

	$('#sg-demo-set').click(function() {
		$.cookie("theme-color", sg_demo_val.color_id, {expires: 365, path: '/'});
		$.cookie("Theme|color", sg_demo_val.color, {expires: 365, path: '/'});
		$.cookie("body-pattern", sg_demo_val.pattern_id, {expires: 365, path: '/'});
		$.cookie("Theme|pattern", sg_demo_val.pattern, {expires: 365, path: '/'});
		window.location.reload();
		return false;
	});

	$('#sg-demo-reset').click(function() {
		$.cookie("theme-color", 0, {expires: -1, path: '/'});
		$.cookie("Theme|color", 0, {expires: -1, path: '/'});
		$.cookie("body-pattern", 0, {expires: -1, path: '/'});
		$.cookie("Theme|pattern", 0, {expires: -1, path: '/'});
		window.location.reload();
		return false;
	});
});